package com.transitionseverywhere;

import android.graphics.Rect;
import android.view.ViewGroup;

/* loaded from: classes.dex */
public class SidePropagation extends VisibilityPropagation {
    private static final String TAG = "SlidePropagation";
    private float mPropagationSpeed = 3.0f;
    private int mSide = 80;

    public void setSide(int i) {
        this.mSide = i;
    }

    public void setPropagationSpeed(float f) {
        if (f == 0.0f) {
            throw new IllegalArgumentException("propagationSpeed may not be 0");
        }
        this.mPropagationSpeed = f;
    }

    @Override // com.transitionseverywhere.TransitionPropagation
    public long getStartDelay(ViewGroup viewGroup, Transition transition, TransitionValues transitionValues, TransitionValues transitionValues2) {
        int i;
        int i2;
        int i3;
        TransitionValues transitionValues3 = transitionValues;
        if (transitionValues3 == null && transitionValues2 == null) {
            return 0L;
        }
        Rect epicenter = transition.getEpicenter();
        if (transitionValues2 == null || getViewVisibility(transitionValues3) == 0) {
            i = -1;
        } else {
            transitionValues3 = transitionValues2;
            i = 1;
        }
        int viewX = getViewX(transitionValues3);
        int viewY = getViewY(transitionValues3);
        int[] iArr = new int[2];
        viewGroup.getLocationOnScreen(iArr);
        int round = iArr[0] + Math.round(viewGroup.getTranslationX());
        int round2 = iArr[1] + Math.round(viewGroup.getTranslationY());
        int width = round + viewGroup.getWidth();
        int height = round2 + viewGroup.getHeight();
        if (epicenter != null) {
            i2 = epicenter.centerX();
            i3 = epicenter.centerY();
        } else {
            i2 = (round + width) / 2;
            i3 = (round2 + height) / 2;
        }
        float distance = distance(viewGroup, viewX, viewY, i2, i3, round, round2, width, height) / getMaxDistance(viewGroup);
        long duration = transition.getDuration();
        if (duration < 0) {
            duration = 300;
        }
        return Math.round((((float) (duration * i)) / this.mPropagationSpeed) * distance);
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x001c, code lost:
        if (com.transitionseverywhere.utils.ViewUtils.isRtl(r5) != false) goto L23;
     */
    /* JADX WARN: Code restructure failed: missing block: B:5:0x000d, code lost:
        if (com.transitionseverywhere.utils.ViewUtils.isRtl(r5) != false) goto L5;
     */
    /* JADX WARN: Code restructure failed: missing block: B:6:0x000f, code lost:
        r0 = 5;
     */
    /* JADX WARN: Code restructure failed: missing block: B:7:0x0011, code lost:
        r0 = 3;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    private int distance(android.view.View r5, int r6, int r7, int r8, int r9, int r10, int r11, int r12, int r13) {
        /*
            r4 = this;
            int r0 = r4.mSide
            r1 = 5
            r2 = 3
            r3 = 8388611(0x800003, float:1.1754948E-38)
            if (r0 != r3) goto L13
            boolean r5 = com.transitionseverywhere.utils.ViewUtils.isRtl(r5)
            if (r5 == 0) goto L11
        Lf:
            r0 = 5
            goto L1f
        L11:
            r0 = 3
            goto L1f
        L13:
            r3 = 8388613(0x800005, float:1.175495E-38)
            if (r0 != r3) goto L1f
            boolean r5 = com.transitionseverywhere.utils.ViewUtils.isRtl(r5)
            if (r5 == 0) goto Lf
            goto L11
        L1f:
            r5 = 0
            if (r0 == r2) goto L45
            if (r0 == r1) goto L3d
            r9 = 48
            if (r0 == r9) goto L35
            r9 = 80
            if (r0 == r9) goto L2d
            goto L4c
        L2d:
            int r7 = r7 - r11
            int r8 = r8 - r6
            int r5 = java.lang.Math.abs(r8)
            int r5 = r5 + r7
            goto L4c
        L35:
            int r13 = r13 - r7
            int r8 = r8 - r6
            int r5 = java.lang.Math.abs(r8)
            int r5 = r5 + r13
            goto L4c
        L3d:
            int r6 = r6 - r10
            int r9 = r9 - r7
            int r5 = java.lang.Math.abs(r9)
            int r5 = r5 + r6
            goto L4c
        L45:
            int r12 = r12 - r6
            int r9 = r9 - r7
            int r5 = java.lang.Math.abs(r9)
            int r5 = r5 + r12
        L4c:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: com.transitionseverywhere.SidePropagation.distance(android.view.View, int, int, int, int, int, int, int, int):int");
    }

    private int getMaxDistance(ViewGroup viewGroup) {
        int i = this.mSide;
        if (i == 3 || i == 5 || i == 8388611 || i == 8388613) {
            return viewGroup.getWidth();
        }
        return viewGroup.getHeight();
    }
}
